#define _CRT_SECURE_NO_WARNINGS 2
#pragma once
#include<cstdio>
#include<cstdlib>
#include<iostream>

using  namespace std;

#define CAPACITY	20

typedef int DataType;

typedef  struct Stack
{
	DataType* arr;
	int capacity;
	int top;
}ST;

void STInit(ST* st)
{
	st->arr = (DataType*)malloc(CAPACITY*sizeof(DataType));
	st->capacity = CAPACITY;
	st->top = 0;
}

void STDestroy(ST* st)
{
	free(st->arr);
	st->capacity = 0;
	st->top = 0;
}

void STPush(ST* st, DataType val)
{
	if (st->capacity == st->top)
	{
		st->arr = (DataType*)realloc(st->arr, sizeof(DataType) * 2 * (st->capacity));
	}
	st->arr[st->top++] = val;
}

void STPop(ST* st)
{
	st->top--;
}

DataType STTop(ST* st)
{
	return st->arr[st->top - 1];
}

bool STEmpty(ST* st)
{
	return st->top == 0;
}

int STSize(ST* st)
{
	return st->top;
}

void STPrint(ST* st)
{
	int i = 0;
	while (i < st->top)
	{
		cout << st->arr[i++] << " ";
	}
	cout << endl;
}